home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1999 August / SGI IRIX Base Documentation 1999 August.iso / CDrelnotes < prev    next >
Text File  |  1999-02-03  |  3KB  |  143 lines

  1. #! /bin/sh
  2. #Tag 0x00000600
  3. PATH=$PATH:/usr/bin
  4.  
  5. # 'CDrelnotes' - View on-line release notes
  6.  
  7. SRCDIR=`dirname $0`/usr/relnotes/
  8.  
  9. Usage="\n
  10.     'CDrelnotes -h' -- print this message\n
  11.     'CDrelnotes' -- list products that have on-line release notes \n
  12. \t\t\tcurrently installed\n
  13.     'CDrelnotes <product>' -- show table of contents for a product's \n
  14. \t\t\ton-line release notes\n
  15.     'CDrelnotes <product> <chapter> ... ' -- display specific chapters of \n
  16. \t\t\t\ta product's on-line release notes\n
  17.     'CDrelnotes -t <product> <chapter> ... ' -- print specific chapters of \n
  18. \t\t\t\ta product's on-line release notes\n"
  19.  
  20. if [ "$1" = "-h" ] # give help and exit
  21. then
  22.     echo $Usage
  23.     exit
  24. fi
  25.  
  26. list_relnotes=/tmp/relnoteslist$$
  27. product=/tmp/relnotesproduct$$
  28. cleanup="rm -f $list_relnotes $product"
  29. trap "$cleanup" 1 2 3 15
  30.  
  31. # Create a list of products which have release notes installed.
  32. HERE=`pwd`
  33. cd $SRCDIR
  34. find . -follow -type f -name "ch*.z" -print |  \
  35.     sed -e 's%./%%' -e 's%/ch.*\.z%%' | sort -u > $list_relnotes
  36. cd $HERE
  37. if [ ! -s $list_relnotes ]
  38. then
  39.     echo "Sorry, but no products have release notes installed\n"
  40.     rm -f $list_relnotes
  41.     exit
  42. fi
  43.  
  44. if [ $# -eq 0 ]    # no args - show installed relnotes
  45. then
  46.     echo "The following products have release notes installed:\n"
  47.     cat $list_relnotes
  48.     $cleanup
  49.     exit
  50. fi
  51.  
  52. validproduct=no
  53. tflag=
  54. while [ $# -gt 0 ] # As long as we have arguments ....
  55. do
  56.     # Recognize old-style args, but don't support them.
  57.     if [ "$1" = "-p" ]
  58.     then
  59.       echo "The -p and -c options are no longer needed."
  60.       echo $Usage
  61.       $cleanup 
  62.       exit 1
  63.     fi
  64.  
  65.     # Support for printing chapters.
  66.     if [ "$1" = "-t" ]
  67.     then
  68.       tflag=$1
  69.       shift 
  70.       continue
  71.     fi
  72.     
  73.     # Invalid option?
  74.     if [ "$1" = "--" ]
  75.     then
  76.       echo "$1 is an invalid option."
  77.       echo $Usage
  78.       $cleanup
  79.       exit 1
  80.     fi
  81.     
  82.         # Invalid option?
  83.         case "$1" {
  84.         -*)
  85.           echo "$1 is an invalid option."
  86.           echo $Usage
  87.           $cleanup
  88.           exit 1
  89.           ;;
  90.         }
  91.  
  92.     if [ "$validproduct" = "no" ]
  93.     then
  94.       echo $1 > $product
  95.       match=`comm -12 $list_relnotes $product  | wc -l`
  96.       if [ $match -eq 1 ];
  97.       then
  98.          validproduct=$1    
  99.          shift
  100.          if [ $# -gt 0 ];
  101.          then
  102.             continue
  103.          fi
  104.          if [ -f $SRCDIR$validproduct/TC ];
  105.          then
  106.             echo "The chapters for the \"$validproduct\" product's release notes are:\n"
  107.             cat $SRCDIR$validproduct/TC 
  108.          else
  109.             echo "The \"$validproduct\" product's release notes are installed, "
  110.             echo "but its table of contents file is missing.\n"
  111.             echo "The chapters that are installed are:\n"
  112.             cd $SRCDIR${validproduct}; /bin/ls ch*.z | sed -e 's/ch//' -e 's/.z//'
  113.          fi
  114.       else  # Not an installed product
  115.          echo "Sorry, but there are no installed release notes for the \"$1\" product.\n"
  116.          $cleanup ; exit 1
  117.       fi
  118.     else # Have a valid product.
  119.       cd $SRCDIR$validproduct
  120.           # Check for the existence of ch#.z. If not found check
  121.           # for ch0#.z. If still not found report an error
  122.           if [ -r ch${1}.z ]; then
  123.                 man $tflag -d ch${1}.z
  124.           elif [ -r ch0${1}.z ]; then
  125.                 man $tflag -d ch0${1}.z
  126.           else
  127.                 echo "There is no chapter $1 in the \"$validproduct\" release notes."
  128.           fi
  129.       shift
  130.       if [ $# -gt 0 ];
  131.       then
  132.         echo "Next chapter ('q' to quit):\c"
  133.         read ans
  134.         if [ "$ans" = "q" ];
  135.         then
  136.             $cleanup
  137.             exit
  138.         fi
  139.       fi
  140.     fi
  141. done
  142. $cleanup
  143.